﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Dropit.BlogPageProvider.Blogger
{
	public class BloggerId
	{
		#region Fields

		private string _blogId;
		private string _postId;
		private string _commentId;

		#endregion

		#region Properties

		public string BlogId
		{
			get { return _blogId ?? string.Empty; }
			set { _blogId = value; }
		}

		public string PostId
		{
			get { return _postId ?? string.Empty; }
			set { _postId = value; }
		}

		public string CommentId
		{
			get { return _commentId ?? string.Empty; }
			set { _commentId = value; }
		}

		#endregion

		#region Methods

		public static bool TryParse(string data, out BloggerId id)
		{
			if (!string.IsNullOrEmpty(data))
			{
				string[] parts = data.Split('|');
				if (parts.Length == 3)
				{
					id = new BloggerId();
					id.BlogId = parts[0];
					id.PostId = parts[1];
					id.CommentId = parts[2];
					return true;
				}
			}
			id = null;
			return false;
		}

		public override string ToString()
		{
			return string.Format("{0}|{1}|{2}", BlogId, PostId, CommentId);
		}

		#endregion
	}
}
